Early Access: The content on this website is provided for informational purposes only in connection with pre-General Availability Qlik Products.
All content is subject to change and is provided without warranty.
Skip to main content Skip to complementary content

Memory management methods

The following methods can be called to utilize Replicate's memory management procedures.

create_pool

Creates a new memory pool.

Syntax

create_pool (AR_AO_MPOOL *parentPool, 
char *poolName, 
AR_AO_MPOOL **newPool); 
create_pool parameters
Parameter Type Description

parentPool

AR_AO_MPOOL

The pool to allocate from (required).

poolName

char

The new memory pool name (optional).

Information note

The poolName value is assumed to be a static, unmanaged space that does not need to be freed. The value will not be copied internally.

newPool

AR_AO_MPOOL

Returns the new memory pool.

destroy_pool

Deletes the given pool and deallocates the memory associated with it.

Information note

Using the clear_pool method (described below) will provide much better performance than using the destroy_pool and create_pool methods.

Syntax

destroy_pool (AR_AO_MPOOL *Pool); 
destroy_pool parameters
Parameter Type Description

Pool

AR_AO_MPOOL

The pool to destroy.

clear_pool

Deallocates the memory associated with a given pool.

Syntax

clear_pool (AR_AO_MPOOL *pool); 
clear_pool parameters
Parameter Type Description

pool

AR_AO_MPOOL

The pool to deallocate.

calloc

Performs the following operations:

  • Allocates memory from a given pool

    Information note

    Different pools can be used to allocate memory on multiple threads concurrently. However, it's not thread safe to do this on the same pool.

  • Allocates a buffer and sets all bytes to zero
  • Aborts a process if no memory remains

Syntax

calloc (AR_AO_MPOOL *pool, 
size_t *size
); 
calloc parameters
Parameter Type Description

pool

AR_AO_MPOOL

The pool to allocate memory from.

size

size_t

The size of the buffer to allocate.

get_ctx_pool

Returns the ctx (context) thread pool (and creates a new pool if needed). Using ctx pool per thread minimizes the chances of a crash as each addon will have its own pool allocator. The pool will be destroyed automatically if a thread already exists.

Syntax

get_ctx_pool (char *addonName, 
AR_AO_MPOOL *pool 
);
get_ctx_pool parameters
Parameter Type Description

addonName

char

The pool name if one needs to be created (optional).

pool

AR_AO_MPOOL

The ctx pool that the function returns.

get_ctx

Gets the metadata from the thread pool.

Syntax

get_ctx_pool (AR_AO_MPOOL *pool, 
char *key, 
void **data 
);
get_ctx parameters
Parameter Type Description

pool

AR_AO_MPOOL

The ctx pool to get the metadata from.

key

char

The key for the metadata to retrieve.

data

void

The user metadata associated with the pool(returned).

set_ctx

Sets metadata on the thread pool.

Information note

The data to be attached to the pool should have a life span at least as long as the pool to which it is being attached.

Syntax

set_ctx (AR_AO_MPOOL *pool, 
char *key, 
void *data, 
AR_ADDONS_MEM_CTX_CLEANUP cleanup
); 
set_ctx parameters
Parameter Type Description

pool

AR_AO_MPOOL

The ctx pool.

key

char

The key for the metadata to retrieve.

data

void

The user metadata to be associated with the pool.

cleanup

AR_ADDONS_MEM_CTX_CLEANUP

Cleans the data when pool is destroyed. Returns "0" on success.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!